#!/usr/local/bin/python3
# -*- coding: utf-8 -*-

"""
@File    : exp_ret_format.py
@Author  : different
@Time    : 2021-8-9 10:15
@Desc    :

"""
import math


# 价格区间
def interval_equally(_min, _max, n=5) -> list:
    """
    价格区间划分
    :param _min: 最小值
    :param _max: 最大值
    :param n: 区间数
    :return: 返回区间列表
    """
    __ret_arr = []
    ls = []
    if _min < 100:
        multiple = 10
        coe = 0.1
    elif _min < 1000:
        multiple = 100
        coe = 1
    else:
        multiple = 1000
        coe = 10
    _min = math.floor(_min / multiple) * multiple
    _max = math.ceil(_max / multiple) * multiple
    _m = _max - _min
    quotient = int(_m / n)
    remainder = _m % n

    __ret_arr = [round(quotient / multiple) * multiple] * (n - 1 - remainder) + [
        round(quotient / multiple + coe) * multiple] * (remainder + 1)

    ls.append(_min)
    for i in __ret_arr:
        _min += i
        ls.append(_min)
    ls.append(_max)
    return ls


def fmt_add_time(data):
    for i in data:
        i['name'] = i['name'].split('.')[1]
    return data


if __name__ == '__main__':
    pass
